git log 查看某文件的修改历史 您所在的位置:网站首页 git log 图形化 git log 查看某文件的修改历史

git log 查看某文件的修改历史

2024-04-24 06:30| 来源: 网络整理| 查看: 265

先进入此文件所在的目录下

1. git log --help

所有的git命令都可以通过git manual查看

在synopsis中可以看到公式 git log [] [[--] ] 其中 []中的内容可以为空

每个option都有相应的解释

git log --help

GIT-LOG(1) Git Manual GIT-LOG(1) NAME git-log - Show commit logs SYNOPSIS git log [] [] [[--] ...] DESCRIPTION Shows the commit logs. The command takes options applicable to the git rev-list command to control what is shown and how, and options applicable to the git diff-* commands to control how the changes each commit introduces are shown. OPTIONS --follow Continue listing the history of a file beyond renames (works only for a single file). --no-decorate, --decorate[=short|full|no] Print out the ref names of any commits that are shown. If short is specified, the ref name prefixes refs/heads/, refs/tags/ and refs/remotes/ will not be printed. If full is specified, the full ref name (including prefix) will be printed. The default option is short. :

2. git log -- filename (git log filename)

可以看到该文件相关的commit记录

git log -- README.md

commit 83bb011fac7cd4b94c7e711fc1b4457c43b0e60d Author: lin Date: Fri Jun 2 10:47:11 2017 +0800 测试 Change-Id: Ifbbb04e664407bb89f726bf967d2847ed211a949 commit 999e31080f96c29d84e11a82e87bfa175976fe0e Author: lin Date: Fri Apr 21 10:13:19 2017 +0800 测试 Change-Id: Iafb710f80d7970d052a0298ece955ce1fc3840ed commit 0eaa6ba18abde83622379f152d42f63754a6fd5c Author: lin Date: Fri Apr 21 10:12:28 2017 +080

3. git log -p filename

可以显示该文件每次提交的diff

git log -p README.md

commit 83bb011fac7cd4b94c7e711fc1b4457c43b0e60d Author: lin Date: Fri Jun 2 10:47:11 2017 +0800 测试 Change-Id: Ifbbb04e664407bb89f726bf967d2847ed211a949 diff --git a/README.md b/README.md index 565897b..85c6bcf 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,9 @@ add a line ss 新加一行, 完善一下 for ticket 11 - +UUU home test and 11 +2017-06-02 10:46

4. git show commit-id filename

查看某次提交中的某个文件变化

git show 999e31080f96c29d84e11a82e87bfa175976fe0e README.md

commit 999e31080f96c29d84e11a82e87bfa175976fe0e Author: lin Date: Fri Apr 21 10:13:19 2017 +0800 测试 Change-Id: Iafb710f80d7970d052a0298ece955ce1fc3840ed diff --git a/README.md b/README.md index 8b79f6f..565897b 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Add a little content Srebase i add a line - +ss 新加一行, 完善一下 for ticket 11 (END)

5.git show commit-id

根据commit-id查看某个提交

6. gitk --follow filename

  以图形化的界面显示文件修改列表,

7.借助可视化工具 如 sourceTree 在最后一次修改的记录上 右键选中文件 查看历史修改

8.git log 的常用选项

选项

说明

-p

按补丁格式显示每个更新之间的差异。

--stat

显示每次更新的文件修改统计信息。

--shortstat

只显示 --stat 中最后的行数修改添加移除统计。

--name-only

仅在提交信息后显示已修改的文件清单。

--name-status

显示新增、修改、删除的文件清单。

--abbrev-commit

仅显示 SHA-1 的前几个字符,而非所有的 40 个字符。

--relative-date

使用较短的相对时间显示(比如,“2 weeks ago”)。

--graph

显示 ASCII 图形表示的分支合并历史。

--pretty

使用其他格式显示历史提交信息。可用的选项包括 oneline,short,full,fuller 和 format(后跟指定格式)。

选项

说明

-(n)

仅显示最近的 n 条提交

--since, --after

仅显示指定时间之后的提交。

--until, --before

仅显示指定时间之前的提交。

--author

仅显示指定作者相关的提交。

--committer

仅显示指定提交者相关的提交。

--grep

仅显示含指定关键字的提交

-S

仅显示添加或移除了某个关键字的提交



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有